helloApp.service('HobbyService', function ($http) {

    this.urlBase = "/api/hobby";

    this.saveList = function(idUser, hobbyList, callback) {

        $http({
            method: "POST",
            url: this.urlBase+"/save/list/"+idUser,
            data: angular.toJson(hobbyList)
        }).success(callback);
    };

    this.updateList = function(idUser, hobbyList, callback) {
        $http({
            method: "PUT",
            url: this.urlBase+"/update/list/"+idUser,
            data: angular.toJson(hobbyList)
        }).success(callback);
    };

    this.getHobbiesByUser = function(idUser, callback) {
        $http({
            method: "GET",
            url: this.urlBase+"/hobbies/"+idUser
        }).success(callback);
    };

    this.delete = function(id, callback) {
        $http.delete(this.urlBase+"/"+id).success(callback);
    };
});